package com.xz.courseschedule.controller;

import com.xz.courseschedule.entity.Room;
import com.xz.courseschedule.service.RoomService;
import com.xz.courseschedule.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 教室管理控制器
 * @Author: zys
 * @CreateTime: 2025-05-24
 */
@Tag(name = "教室管理", description = "教室信息的管理和查询")
@RestController
@RequestMapping("/room")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @Operation(summary = "获取教室列表", description = "获取系统中所有教室的信息列表")
    @GetMapping("/getList")
    public Result getList(){
        return roomService.getList();
    }

    @Operation(summary = "根据ID获取教室", description = "根据教室ID获取单个教室的详细信息")
    @Parameter(name = "id", description = "教室ID", required = true)
    @GetMapping("/get/{id}")
    public Result getById(@PathVariable Long id){
        return roomService.getById(id);
    }

    @Operation(summary = "新增教室", description = "添加新的教室到系统中")
    @PostMapping("/add")
    public Result add(@RequestBody Room room){
        return roomService.add(room);
    }

    @Operation(summary = "更新教室", description = "更新指定的教室信息")
    @PutMapping("/update")
    public Result update(@RequestBody Room room){
        return roomService.update(room);
    }

    @Operation(summary = "删除教室", description = "根据教室ID删除指定的教室")
    @Parameter(name = "id", description = "教室ID", required = true)
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return roomService.delete(id);
    }

    @Operation(summary = "批量删除教室", description = "根据教室ID列表批量删除教室")
    @DeleteMapping("/deleteBatch")
    public Result deleteBatch(@RequestBody Long[] ids){
        return roomService.deleteBatch(ids);
    }
}
